<?php

/**
 * @author Christopher Hazekamp
 * @copyright 2013
 */

//$db = new PDO("mysql:host=localhost;dbname=portfolio_db;", 'root', '');
//$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
//$db->setFetchMode(PDO::FETCH_ASSOC);
require('pdo.php');
$db = new Database;

?>

<a href="index.php">Overzicht</a>

<?php
if (isset($_POST['submit']))
{
	/*$db->beginTransaction();
	$db->query("INSERT INTO people (name,location,gender) VALUES (:name, :location, :gender)");
	$db->bind(':name', $_POST['name']);
	$db->bind(':location', $_POST['location']);
	$db->bind(':gender', $_POST['gender']);
	$db->execute();
	$db->endTransaction();*/
	$post = array(
		'name' => $_POST['name'],
		'location' => $_POST['location'],
		'gender' => $_POST['gender']
	);
	$newId = $db->sqlInsert('people', $post);
	echo '<br />' . $_POST['name'] . ' (' . $_POST['gender'] .  ') from ' . $_POST['location'] . ' with ID number ' . $newId . ' was succesfuly added!<br />';
}
else
{
	?>
	<form action="" method="post" id="insertvalue">
		<label>Name:</label><br />
		<input type="text" name="name" value="" /><br /><br />
		
		<label>Location:</label><br />
		<input type="text" name="location" value="" /><br /><br />
		
		<label>Gender:</label><br />
		<select name="gender">
			<option value="m">Male</option>
			<option value="f">Female</option>
		</select><br /><br />
		
		<input type="submit" name="submit" value="Submit" />
	</form>
	<?php
}
//$db->bind('page_id', 3);

?>